using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// Wiki_Path -  维基目录 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IWikiPath<T> :ModelBase<WikiPath> where T : WikiPath, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.PathId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return PathId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.PathId=dy.PathId;
           this.Title=dy.Title;
           this.SuperiorPath=dy.SuperiorPath;
           this.Path=dy.Path;
           this.PathCount=dy.PathCount;
           this.SubmitTime=dy.SubmitTime;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 目录ID
        /// </summary>
        private String _PathId = "";
      
        /// <summary>
        /// 目录ID
        /// </summary>
        public String PathId
        {
            get 
            {
              return   (this._PathId); 
            }

            set 
            {
                    _PathId= value;  
            }
        }
       
     
         /// <summary>
        /// 标题
        /// </summary>
        private String _Title = "";
      
        /// <summary>
        /// 标题
        /// </summary>
        public String Title
        {
            get 
            {
              return   (this._Title); 
            }

            set 
            {
                    _Title= value;  
            }
        }
       
     
         /// <summary>
        /// 上级目录
        /// </summary>
        private String _SuperiorPath = "";
      
        /// <summary>
        /// 上级目录
        /// </summary>
        public String SuperiorPath
        {
            get 
            {
              return   (this._SuperiorPath); 
            }

            set 
            {
                    _SuperiorPath= value;  
            }
        }
       
     
         /// <summary>
        /// 路径
        /// </summary>
        private String _Path = "";
      
        /// <summary>
        /// 路径
        /// </summary>
        public String Path
        {
            get 
            {
              return   (this._Path); 
            }

            set 
            {
                    _Path= value;  
            }
        }
       
     
         /// <summary>
        /// 目录深度
        /// </summary>
        private int _PathCount =int.MinValue;
      
        /// <summary>
        /// 目录深度
        /// </summary>
        public int PathCount
        {
            get 
            {
              return   (this._PathCount); 
            }

            set 
            {
                    _PathCount= value;  
            }
        }
       
     
         /// <summary>
        /// 创建时间
        /// </summary>
        private DateTime _SubmitTime =DateTime.MinValue;
      
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime SubmitTime
        {
            get 
            {
              return   (this._SubmitTime); 
            }

            set 
            {
                    _SubmitTime= value;  
            }
        }
       
     
        
       

      #endregion 定义属性 

          protected internal override void SetValue(WikiPath info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["PathId"]!= DBNull.Value)
                  {
                  info.PathId=row["PathId"].ToString();
                 }
                 
                  
                  if(row["Title"]!= DBNull.Value)
                  {
                  info.Title=row["Title"].ToString();
                 }
                 
                  
                  if(row["SuperiorPath"]!= DBNull.Value)
                  {
                  info.SuperiorPath=row["SuperiorPath"].ToString();
                 }
                 
                  
                  if(row["Path"]!= DBNull.Value)
                  {
                  info.Path=row["Path"].ToString();
                 }
                 
                  
                  if(row["PathCount"]!= DBNull.Value)
                  {
                  info.PathCount=Convert.ToInt32(row["PathCount"]);
                 }
                 
                  
                  if(row["SubmitTime"]!= DBNull.Value)
                  {
                  info.SubmitTime=Convert.ToDateTime(row["SubmitTime"]);
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, WikiPath info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@PathId", DbType.String,ParameterTool.GetObj( info._PathId )); 
            
             
                cn.AddInParameter(comm, "@Title", DbType.String,ParameterTool.GetObj( info._Title )); 
            
             
                cn.AddInParameter(comm, "@SuperiorPath", DbType.String,ParameterTool.GetObj( info._SuperiorPath )); 
            
             
                cn.AddInParameter(comm, "@Path", DbType.String,ParameterTool.GetObj( info._Path )); 
            
             
                cn.AddInParameter(comm, "@PathCount", DbType.Int32,ParameterTool.GetObj( info._PathCount )); 
            
             
                cn.AddInParameter(comm, "@SubmitTime", DbType.DateTime,ParameterTool.GetObj( info._SubmitTime )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 